function authorAddShowPostAuthorResult(info) {
    var handle = $('#post-author-result');

    info = "<li>" + info + "</li>";
    handle.append(info);
}

function onAuthorAddAuthorAddButtonClick() {
    var authorTitleHandle = $('#author-title');
    var authorIntroductionHandle = $('#author-introduction');

    var authorTitle = authorTitleHandle.val();
    var authorIntroduction = authorIntroductionHandle.val();

    if (authorTitle == null || authorTitle == '') {
        authorAddShowPostAuthorResult("作者名字必须填写");
        return;
    }

    if (authorIntroduction == null || authorIntroduction == '') {
        authorAddShowPostAuthorResult("作者介绍必须填写");
        return;
    }

    $.ajax({
        type: 'post',
        async: true,
        data: {"author": authorTitle, "introduction": authorIntroduction},
        url: document.location.origin + '/api/addauthor',
        dataType: 'text',
        error: function() {

        },
        success: function(data) {
            var json = JSON.parse(data);

            if (json.result == 200) {
                authorAddShowPostAuthorResult("添加作者：<strong>" + authorTitle + "</strong> 成功");
                authorTitleHandle.val('');
                authorIntroductionHandle.val('');

            }
            else {
                authorAddShowPostAuthorResult(json.description);
            }
        }
    });
}

function onAuthorAddCancelButtonClick() {

}